package com.cwnu.onlinemall.service;

import com.cwnu.onlinemall.mapper.MallCategoryMapper;
import com.cwnu.onlinemall.pojo.MallCategory;
import com.cwnu.onlinemall.pojo.MallProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService{

    @Autowired
    MallCategoryMapper mallCategoryMapper;

    @Override
    public List<MallCategory> selectAll() {
        return mallCategoryMapper.selectByExample(null);
    }

    @Override
    public MallCategory selectById(Integer id) {
        MallCategory mallCategory = mallCategoryMapper.selectByPrimaryKey(id);
        return mallCategory;
    }

    @Override
    public Integer insert(MallCategory mallCategory) {
        int insertRow = mallCategoryMapper.insertSelective(mallCategory);
        return insertRow;
    }

    @Override
    public Integer deleteById(Integer id) {
        return mallCategoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer updateById(MallCategory mallCategory) {
        return mallCategoryMapper.updateByPrimaryKeySelective(mallCategory);
    }
}
